﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using GameEngine.Entities;
using GameEngine.EntityComponents;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using PvT.Entities.HUD;

namespace PvT.Entities
{
    public class GameHudEntity : AbstractEntity
    {
        /// <summary>
        /// Initializes a new instance of the <see cref="GameHudEntity" /> class.
        /// </summary>
        /// <param name="components">The components.</param>
        /// <param name="isActive">if set to <c>true</c> [is active].</param>
        /// <param name="isVisible">if set to <c>true</c> [is visible].</param>
        /// <param name="position">The position.</param>
        /// <param name="game">The game.</param>
        public GameHudEntity(List<IEntityComponent> components, bool isActive, bool isVisible, Vector2 position, Game game) :
            base(components, isActive, isVisible, position, game)
        { }

        /// <summary>
        /// Loads the content.
        /// </summary>
        public override void LoadContent()
        {
            LoadChildren();

            base.texture = game.Content.Load<Texture2D>("redpicture");
            base.position = new Vector2(0,0);
            base.scale = 0.001f;
        }

        /// <summary>
        /// Loads the children.
        /// </summary>
        public void LoadChildren()
        {
            HealthBarHudEntity healthbar = new HealthBarHudEntity(new List<GameEngine.EntityComponents.IEntityComponent>(), true, true,
                new Vector2(game.GraphicsDevice.Viewport.TitleSafeArea.Left, game.GraphicsDevice.Viewport.TitleSafeArea.Top), game);
            healthbar.LoadContent();
            this.children.Add(healthbar);
        }

        /// <summary>
        /// Sets the player.
        /// </summary>
        /// <param name="playerEntity">The player entity.</param>
        public void SetPlayer(PlayerEntity playerEntity)
        {
            foreach (AbstractEntity entity in children)
            {
                ((AbstractHudEntity)entity).SetPlayer(playerEntity);
            }
        }
    }
}
